/*
 * CAnthill.cpp
 *
 *  Created on: 14 Oct 2012
 *      Author: Mario Kleinsasser
 *		Time:	17:19:53
 */

#include <iostream>
#include <typeinfo>
#include "CAnthill.h"
#include "CAnt.h"
#include "CEnvironment.h"
#include <time.h>
#include <stdlib.h>

using namespace std;

int CAnthill::act(){
	print();
	return 0;
}

void CAnthill::print(){
	cout << "H" ;
}

void CAnthill::addAntToAnthill(CItem *ant){

	/*
	 *  insert ant into list of ants
	 *  push it at front and take it from
	 *  check if we realy get an ant back :-)
	 */

	try {
		this->antList.push_front(dynamic_cast<CAnt*>(ant));
	} catch (bad_cast&) {
		cout << "That was not an ant!";
	}


}

CAnthill::CAnthill(int defFood) {

	/*
	 * Define the food count inside the Anthill
	 * If the constructor is not initialized on creation
	 * the default value of the constructor in CAnthill.h is 200
	 */
	food = defFood;

	/*
	 * Get the environment singelton so I could calculate the M N random
	 */

	CEnvironment* environment = CEnvironment::getInstance(10, 10);

	this->M = rand() % environment->getM();
	this->N = rand() % environment->getN();

	/*
	 * If we know where we are, place the Anthill himself into playground
	 * and store the N M values inside the the Anthill
	 */
	environment->getPlayground()->getArea(M,N)->setType(this);

}

CAnthill::~CAnthill() {
	// TODO Auto-generated destructor stub
}




